package com.ccx.service.impl;

import com.ccx.mapper.EbCommentMapper;
import com.ccx.model.EbComment;
import com.ccx.model.EbCommentExample;
import com.ccx.service.EbCommentService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EbCommentServiceimpl implements EbCommentService {

    @Autowired
    EbCommentMapper ebCommentMapper;
    /**
     * 添加
     */
    public int insertTest(EbComment ebComment){
        return ebCommentMapper.insertSelective(ebComment);
    }

    /**
     * 查询
     */
    public List<EbComment> selectSuccess(int ecId,String nickName){
        EbCommentExample ebCommentExample = new EbCommentExample();


        EbCommentExample.Criteria criteria = ebCommentExample.createCriteria();
        criteria.andEcIdEqualTo(ecId).andEcNickNameEqualTo(nickName);

                    // select * from xx
        return ebCommentMapper.selectByExample(ebCommentExample);
    }


    /**
     * 修改
     */
    public int updateTest(EbComment ebComment){
        return ebCommentMapper.updateByPrimaryKeySelective(ebComment);
    }

    /**
     * 删除
     */
    public int deleteTest(int ecId){
        return ebCommentMapper.deleteByPrimaryKey(ecId);
    }


    /**
     * 分页查询
     */
    public List<EbComment> pageTest(int pageNum,int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        return ebCommentMapper.selectByExample(null);
    }

    @Override
    public EbComment selectById(int ecId) {
        return ebCommentMapper.selectByPrimaryKey(ecId);
    }
}
